package org.akomantoso.core.data;

import java.io.IOException;

import org.akomantoso.core.data.attribute.OptValue;
import org.akomantoso.core.io.Input;
import org.akomantoso.core.io.Output;
import org.akomantoso.core.io.OutputUtil;
import org.akomantoso.core.visitor.AKVisitable;
import org.akomantoso.core.visitor.AKVisitor;

/**
 * The element li is an HTML element and is used in Akoma Ntoso as in HTML, for the generic list item (not a pattern).
 * 
 * <pre>
 * <xsd:element name="li">
 * 		<xsd:complexType mixed="true">
 * 			<xsd:choice minOccurs="0" maxOccurs="unbounded">
 * 				<xsd:group ref="inlineCM"/>
 * 				<xsd:element ref="ul"/>
 * 				<xsd:element ref="ol"/>
 * 				<xsd:element ref="p"/>
 *			</xsd:choice>
 * 			<xsd:attributeGroup ref="optvalue"/>
 * 			<xsd:attributeGroup ref="coreopt"/>
 * 		</xsd:complexType>
 * </xsd:element>
 * </pre>
 * 
 * @author <a href="mailto:jacques.militello@gmail.com">Jacques Militello</a>
 * 
 * @since http://www.akomantoso.org/1.0
 */
public class Li extends MixedContentWithCoreOpt<LiElement> implements OptValue , AKVisitable {

	public static final String ELEMENT = "li";
	
	private String _value;
	
	/**
	 * @see org.akomantoso.core.data.attribute.OptValue#getValue()
	 */
	public String getValue() {
		return _value;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.OptValue#setValue(java.lang.String)
	 */
	public void setValue(String value) {
		_value = value;
	}

	/**
	 * @see org.akomantoso.core.data.MixedContent#writeExternal(org.akomantoso.core.io.Output)
	 */
	@Override
	public <E extends Output> void writeExternal(E out) throws IOException {
		super.writeExternal(out);
		OutputUtil.writeAttribute(out, OptValue.ATTRIBUTE, _value);
	}

	/**
	 * @see org.akomantoso.core.data.MixedContent#readExternal(org.akomantoso.core.io.Input)
	 */
	@Override
	public <E extends Input> void readExternal(E in) throws IOException {
		super.readExternal(in);
		_value = in.readAttribute(OptValue.ATTRIBUTE);
	}

	/**
	 * @see org.akomantoso.core.visitor.AKVisitable#accept(org.akomantoso.core.visitor.AKVisitor)
	 */
	@Override
	public void accept(AKVisitor visitor) {
		if (visitor.visitBegin(this)) {
			internalAccept(visitor);
			visitor.visitEnd(this);
		}
	}

	
}
